public class Sale implements DiscountType{

	private double preDiscountTotal;
	private ISalePricing myPricing;

	
	public Sale(double preDiscountTotal){
		this.preDiscountTotal = preDiscountTotal;
	}
	
	
	public double getTotal(){
		return myPricing.getTotal(this);
	}
	
	
	public double getPreDiscountTotal(){
		return preDiscountTotal;
	}
	
	
	public ISalePricing createPricing(int DiscountType, double percentage, double discount, double threshold){
		ISalePricing price=null;
		if(DiscountType==PERCENTAGEDISCOUNT){
			price = new PercentageDiscountPricing(percentage);
		}
		if(DiscountType==ABSOLUTEDISCOUNT){
			price = new AbsoluteDiscountPricing(discount, threshold);
		}
		return price;
	}
	
	
	public void setPricing(ISalePricing pricing){
		myPricing = pricing;
	}
	
	
	public static void main(String[] args) {

			      Sale sale1 = new Sale(100.0);
			      ISalePricing p1, p2, p3, p4,p5;
			      p1 = sale1.createPricing(PERCENTAGEDISCOUNT,10.0,0,0);
			      p2 = sale1.createPricing(PERCENTAGEDISCOUNT,5.0,0,0); 
			      p3 = sale1.createPricing(ABSOLUTEDISCOUNT,0,5,50);  
			      p4 = sale1.createPricing(ABSOLUTEDISCOUNT,0,30,95); 
			      p5 = sale1.createPricing(ABSOLUTEDISCOUNT,0,19,80); 
			      BestForCustomerPricing p = new BestForCustomerPricing(p1);
			      p.add(p1);
			      p.add(p2);
			      p.add(p3);
			      p.add(p4);
			      p.add(p5);
			      BestForStorePricing a = new BestForStorePricing(p1);
			      a.add(p1);
			      a.add(p2);
			      a.add(p3);
			      a.add(p4);
			      a.add(p5);
			      sale1.setPricing(p);
			      System.out.println("BestForCustomer Price = " +
			                           sale1.getTotal() + " EUR");
			      sale1.setPricing(a);
			      System.out.println("BestForStore Price = " +
                          sale1.getTotal() + " EUR");
	}


}
